package cuiyt.designpattern.observer.v2;

import cuiyt.designpattern.observer.v2.observer.SchoolEvent;
import cuiyt.designpattern.observer.v2.observer.SchoolObserver;
import cuiyt.designpattern.observer.v2.vo.Event;

import java.util.ArrayList;
import java.util.List;

public class ClassRoom {

    private List<SchoolObserver> observers = new ArrayList<>();

    public void addObserver(SchoolObserver student){
        this.observers.add(student);
    }


    public void pubEvent(SchoolEvent schoolEvent){
        Event event = schoolEvent.event();
        this.observers.forEach((item)->{
            item.eventChange(event);
        });
    }

}
